////////////////////////////////////////////////////////////////////////////////
// Copyright 2006 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   MultiRowValidator.java
// AUTHOR           :   ric.yik
// DATE CREATE      :   2006/5/2
// DESCRIPTION      :   
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2006/5/2      ric.yik         1.0                 source is created.
//
//
//
////////////////////////////////////////////////////////////////////////////////

package com.erp.app.util.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.erp.framework.controller.form.MultiRow;
import com.erp.framework.util.BeanUtil;
import com.erp.framework.util.CommonUtil;

public class MultiRowValidator {

    private String lineNumberProperty;

    private String tabLabelObjectId;

    public MultiRowValidator() {
        this("");
    }
    
    public MultiRowValidator(String property) {
        super();
        this.setLineNumberProperty(property);
    }

    public String getLineNumberProperty() {
        return lineNumberProperty;
    }

    public MultiRowValidator setLineNumberProperty(String lineNumberProperty) {
        this.lineNumberProperty = lineNumberProperty;
        return this;
    }

    public String getTabLabelObjectId() {
        return tabLabelObjectId;
    }

    public MultiRowValidator setTabLabelObjectId(String tabLabelProperty) {
        this.tabLabelObjectId = tabLabelProperty;
        return this;
    }

    public boolean isSkipMoreValidateOnError(MultiRow row, ActionErrors errors) {
        return true;
    }

    public String getLineNumber(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response, ActionErrors errors, MultiRow row) {
        String line = String.valueOf(BeanUtil.getPropertyDefault(row, this.getLineNumberProperty()));
        return (CommonUtil.isEmpty(line)) ? "(The new line)" : line;
    }

    public void moreValidate(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response, ActionErrors errors, MultiRow row) {
        // NOOP
    }

}
